package com.yeahka.android.lepos;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.SPUtils;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
import java.util.UUID;

public class DeviceInfo {

    public static String getDeviceId(Context context) {
        String deviceId = ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
        return deviceId == null ? "" : deviceId;
    }


    public static String phoneNum(Context context) {

        String line1Number = ((TelephonyManager) context.getSystemService("phone")).getLine1Number();
        return line1Number == null ? "" : line1Number;
    }


    public static String getIP() {
        return NetworkUtils.getIPAddress(true);
    }



    public static String sourceDir(Context context) {
        String str = "";

        try {
            str = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).sourceDir;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return str;
    }


    public static String uuid() {
        String uuid = SPUtils.getInstance().getString("uuid");

        if (!TextUtils.isEmpty(uuid)) {
            return uuid;
        }
        String trim = UUID.randomUUID().toString().trim();
        SPUtils.getInstance().put("uuid", trim);
        return trim;
    }


    public static boolean netState() {
        return NetworkUtils.isWifiAvailable() && NetworkUtils.isWifiConnected();
    }



}
